import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router, middleware } = app;
  const jwt = middleware.token(app.config.jwt);

  // Login-Controller
  router.post('/register', controller.login.register);
  router.post('/login', controller.login.login);
  router.post('/password/edit', jwt, controller.login.editPassword);

  // User-Controller
  router.get('/user/all', jwt, controller.user.queryUserAll);
  router.post('/user/delete', jwt, controller.user.delUser);
  router.post('/user/update', jwt, controller.user.updateUser);

  // Teacher-Controller
  router.get('/teacher/all', jwt, controller.teacher.queryTeacherAll);
  router.post('/teacher/delete', jwt, controller.teacher.delTeacher);
  router.post('/teacher/add', jwt, controller.teacher.addTeacher);
  router.post('/teacher/update', jwt, controller.teacher.updateTeacher);

  // Student-Controller
  router.get('/student/all', jwt, controller.student.queryStudentAll);
  router.post('/student/delete', jwt, controller.student.delTeacher);
  router.post('/student/add', jwt, controller.student.addStudent);
  router.post('/student/update', jwt, controller.student.updateTeacher);
  router.get('/student/num', jwt, controller.student.checkStudentNum);

  // Class-Controller
  router.get('/class/all', jwt, controller.class.queryClassAll);
  router.post('/class/delete', jwt, controller.class.delClass);
  router.post('/class/add', jwt, controller.class.addClass);
  router.get('/class/list', jwt, controller.class.queryClassList);
};
